"use strict";

//放置一些公共变量
var qualityList = ["#32CD32","#4169E1","#993399","#FF8C00","#FF0000"];
var qualityRatio = 50;

function SetupTooltip(){
	var m_ItemIndex = $.GetContextPanel().GetAttributeInt("itemIndex",-1);
	GameEvents.SendCustomGameEventToServer( "C2S_GET_ITEM_DATA", {itemIndex:m_ItemIndex} );
}

function C2S_GET_ITEM_DATA(data){
	$('#attrList').RemoveAndDeleteChildren();
	var itemName = data.itemName;
	var itemLevel = data.itemLevel;
	//var itemQuality = (Number(itemName.substring(9,11)) % qualityRatio) | 0;
	
	if (itemLevel > 1) {
		itemName = itemName +"[+"+itemLevel+"]";
	}
	$('#itemName').text = itemName;
	// var itemQuality = data.itemQuality;
	// $('#itemName').style.color = qualityList[itemQuality];
	for(var i in data.attrs){
		var panel = $.CreatePanel("Panel", $('#attrList'), i);
	    panel.BLoadLayoutSnippet("attr");
	    var lb = panel.FindChildTraverse("lvlb");
	    lb.text = data.attrs[i];
	//    lb.style.color = qualityList[itemQuality];
	
	}
	// var camera = "camera1";
	// var style = "width:400px;height:400px;";
	// if (someCondition) {
	//     camera = "camera2";
	// }

	// var sceneContainer = $("#modelPanel");
	// sceneContainer.BCreateChildren("<DOTAScenePanel style='" + style + "' unit='" + unit + "'/>");
}

(function()
{
	GameEvents.Subscribe( "C2S_GET_ITEM_DATA", C2S_GET_ITEM_DATA );
})();
